{include file="public/header" /}
<span class="layui-breadcrumb">
  <a href="javascript:;">博客</a>
  <a><cite>列表</cite></a>
</span>
<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body">
        <div style="color:#FF5722">网站博客数据</div>
        <div class="layui-form">
          <a class="layui-btn layui-btn-normal layui-btn-sm" target="_blank" href="{:url('Blog/change')}?nav=blog-bloglist">添加</a>

          <div class="layui-form-item" style='margin-top:20px'>
            <div class="layui-inline">
              <label class="layui-form-label">开始时间</label>
              <div class="layui-input-inline">
                <input type="text" class="layui-input" id="start_time" placeholder="yyyy-MM-dd" value="{$data_list['start_time']}">
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">结束时间</label>
              <div class="layui-input-inline">
                <input type="text" class="layui-input" id="end_time" placeholder="yyyy-MM-dd" value="{$data_list['end_time']}">
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">标题</label>
              <div class="layui-input-inline">
                <input type="text" class="layui-input" name='title' placeholder="请输入标题" value="{$data_list['title']}">
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">作者</label>
              <div class="layui-input-inline">
                <input type="text" class="layui-input" name='author' placeholder="请输入作者" value="{$data_list['author']}">
              </div>
            </div>
            <div class="layui-inline">
              <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="sear()">查询</button>
              <a href="{:url('Blog/index')}?nav=blog-bloglist" class="layui-btn layui-btn-sm layui-btn-danger">清空</a>
            </div>
          </div>
      
          <table class="layui-table" >
            <thead>
              <tr>
                <th>标题</th>
                <th>作者</th>
                <th>列表图</th>
                <th>发布时间</th>
                <th>状态</th>
                <th>操作</th>
              </tr> 
            </thead>
            <tbody>
              {volist name="data_list['list']" id="data"}
               <tr>
                <td>{$data.title}</td>
                <td>{$data.author}</td>
                <td><img src="{$data.img}" style='width:150px;cursor:pointer;min-width:150px' onclick="show('{$data.img}')"></td>
                <td>{$data.create_time}</td>             
                <td>{eq name="$data.status" value="1"}正常{else/}已删除{/eq}</td>
                <td>
                  {eq name="$data.status" value="1"}
                    <button type="button" class="layui-btn layui-btn-danger layui-btn-xs" onclick="del({$data.id})">删除</button>
                    <a target="_blank" href="{:url('Blog/change')}?nav=blog-bloglist&id={$data.id}" class="layui-btn layui-btn-xs">编辑</a>
                  {/eq}
                </td>
              </tr>
              {/volist}
              
            </tbody>
          </table>
          {$data_list['list']|raw}

        </div>

      </div>  
    </div>
</div>

{include file="/public/footer" /}
<script>
  /*图片视频放大*/
  function show(url){
      layer.open({
        type: 2,
        title: false,
        area: ['60%', '50%'],
        shade: 0.8,
        closeBtn: 0,
        fixed: false,
        shadeClose: true,
        content: url
      });
  } 

  function del(id){
    layer.confirm('你确定要删除吗', {
      btn: ['确定','取消'] //按钮
    }, function(){
      layer.load();
      $.post("{:url('Blog/del')}",{id:id},function(res){
          if(res.status=='0'){
              layer.closeAll('loading');
              layer.msg(res.msg);
          }
          if(res.status=='1'){
              layer.msg(
              res.msg,{icon: 1,time: 600},
              function(){
                layer.closeAll('loading');
                location.href=location.href;
              });
          }
      })
    });
  }

  //日期
  layui.use('laydate', function(){
     var laydate = layui.laydate;
      laydate.render({
        elem: '#start_time'
      });
      laydate.render({
        elem: '#end_time'
      });
  })
  /*查询*/
  function sear(){
    var start_time=$.trim($("#start_time").val());
    var end_time=$.trim($("#end_time").val());
    var title=$.trim($("input[name='title']").val());
    var author=$.trim($("input[name='author']").val());
    if(start_time=='' && end_time=='' && title=='' && author==''){
        layer.msg('请输入查询条件');
        return false;
    }
    
    window.location.href="{:url('Blog/index')}"+"?nav=blog-bloglist&start_time="+start_time+"&end_time="+end_time+"&title="+title+"&author="+author;  
  }


</script>
